//
//  TestStringExtension.m
//  CocoaMoney
//
//  Created by Daniel Braun on 29/09/06.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//

#import "TestStringExtension.h"
#import "StringExtension.h"

@implementation TestStringExtension
- (void) setUp {
}

- (void) tearDown {
}


- (void) testStringBetween1
{
#define STR @"il n'est pas de sauveur supreme, ni dieu ni cesar ni tribun"
	NSString *org=STR;
	NSString *str=STR;
	NSString *s;
	STAssertEqualObjects(org, str, @"oula\n");
	s=[str stringBetween:nil and:nil inclusive:YES];
	STAssertEqualObjects(org, s, @"stringBetween:nil and:nil NOK");
	s=[str stringBetween:nil and:nil inclusive:NO];
	STAssertEqualObjects(org, s, @"stringBetween:nil and:nil NOK");

	s=[str stringBetween:@"pas" and:nil inclusive:YES];
	STAssertEqualObjects(s, @"pas de sauveur supreme, ni dieu ni cesar ni tribun",  @"stringBetween:s and:nil NOK");
	s=[str stringBetween:@"pas" and:nil inclusive:NO];
	STAssertEqualObjects(s, @" de sauveur supreme, ni dieu ni cesar ni tribun", @"stringBetween:s and:nil NOK");
	
	s=[str stringBetween:@"troll" and:nil inclusive:NO];
	STAssertEqualObjects(s, nil, @"stringBetween:notfound and:nil NOK");

	s=[str stringBetween:nil and:@"dieu" inclusive:YES];
	STAssertEqualObjects(s, @"il n'est pas de sauveur supreme, ni dieu", @"stringBetween:nil and:s NOK");	
	s=[str stringBetween:nil and:@"dieu" inclusive:NO];
	STAssertEqualObjects(s, @"il n'est pas de sauveur supreme, ni ", @"stringBetween:nil and:s NOK");
	s=[str stringBetween:nil and:@"troll" inclusive:NO];
	STAssertEqualObjects(s, nil, @"stringBetween:nil and:notfoud NOK");
	
	s=[str stringBetween:@"pas" and:@"dieu" inclusive:YES];
	STAssertEqualObjects(s, @"pas de sauveur supreme, ni dieu", @"stringBetween:s and:s NOK");
	s=[str stringBetween:@"pas" and:@"dieu" inclusive:NO];
	STAssertEqualObjects(s, @" de sauveur supreme, ni ",  @"stringBetween:s and:s NOK");

}

- (void) testNumberConverter
{
	STAssertTrue(42.0==[@"42.0" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-42.0==[@"-42.0" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-42.0==[@"-42" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"-4200.25" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"-4.200,25" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"-4 200,25" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"- 4 200,25" doubleSmartValue], @"number conversion failed");
	STAssertTrue(4200.25==[@"4 200,25" doubleSmartValue], @"number conversion failed");
	STAssertTrue(4200==[@"4 200" doubleSmartValue], @"number conversion failed");
	STAssertTrue(42.0==[@"trol 42.0" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-42.0==[@"troll-42.0" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-42.0==[@"troll-42" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"troll-4200.25" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"-4.200,25euros" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"-4 200,25 EUROS" doubleSmartValue], @"number conversion failed");
	STAssertTrue(-4200.25==[@"$- 4 200,25" doubleSmartValue], @"number conversion failed");
	STAssertEqualObjects([NSNumber numberWithDouble:-4200.25], [@"$- 4 200,25" numberSmartValue], @"number conversion failed");
	STAssertTrue(nil==[@"$troll" numberSmartValue], @"number conversion failed");

}
@end
